import rasterio
from rasterio.enums import Resampling
import numpy as np


img_input = "./OriginData/ROI_220920.tif"
img_output = "./OutputData/ROIC_220920.tif"
bands_to_keep = list(range(1,13))

def read_img_info(input_file_path):
    with rasterio.open(input_file_path) as src:
        profile = src.profile
        print(profile)

def S2_BandClip(input_file_path,output_file_path):
    with rasterio.open(input_file_path) as src:
        profile = src.profile
        profile.update(count = len(bands_to_keep))

        with rasterio.open(output_file_path,'w',**profile) as dst:
            for i, band in enumerate(bands_to_keep,start=1):
                data = src.read(band)
                dst.write(data,i)
        print("done")
        read_img_info(output_file_path)


if __name__ == "__main__":
    read_img_info(img_input)
    S2_BandClip(img_input,img_output)
